/**
 * 
 */
package com.witframework.meta;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.javalid.annotations.core.JvGroup;
import org.javalid.annotations.validation.MaxLength;
import org.javalid.annotations.validation.NotEmpty;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

import com.witframework.core.WitSimpleNameGenerator;
import com.witframework.core.annotations.Wit;
import com.witframework.core.structure.BaseWitObject;

/**
 * @author wuxinyang
 * Jun 9, 2009 4:47:25 PM
 * 
 */

@MappedSuperclass
public class BaseMetaObject extends BaseWitObject{
	
	@Wit(cnname="索引名称", description="用于引用数据的简单编码,系统自动产生的")	
	private String refcode;
	
	@Wit(cnname="说明",description="关于数据的说明性信息")	
    protected String description;

	@Column(length=32) @Length(max=32) 
	public String getRefcode() {
		if(refcode==null)
			return (String)new WitSimpleNameGenerator().generate(null,this);
		return refcode;
	}
	public void setRefcode(String refcode) {
		this.refcode = refcode;
	}
	@Column(length=255)  
	@JvGroup(groups={"inheritance"},exposeInSubClass=true)	@MaxLength(length=255) @NotEmpty
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}	
	public void generateRefCodeAndOther(){
		setRefcode((String)new WitSimpleNameGenerator().generate(null,this));		
	}
}
